package com.ruoyi.Warehouse.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.Warehouse.domain.Inventorycheckdetails;
import com.ruoyi.Warehouse.service.IInventorycheckdetailsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 盘点明细表Controller
 * 
 * @author ruoyi
 * @date 2025-06-16
 */
@Controller
@RequestMapping("/pims/inventorycheckdetails")
public class InventorycheckdetailsController extends BaseController
{
    private String prefix = "pims/inventorycheckdetails";

    @Autowired
    private IInventorycheckdetailsService inventorycheckdetailsService;

    @RequiresPermissions("pims:inventorycheckdetails:view")
    @GetMapping()
    public String inventorycheckdetails()
    {
        return prefix + "/inventorycheckdetails";
    }

    /**
     * 查询盘点明细表列表
     */
    @RequiresPermissions("pims:inventorycheckdetails:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Inventorycheckdetails inventorycheckdetails)
    {
        startPage();
        List<Inventorycheckdetails> list = inventorycheckdetailsService.selectInventorycheckdetailsList(inventorycheckdetails);
        return getDataTable(list);
    }

    /**
     * 导出盘点明细表列表
     */
    @RequiresPermissions("pims:inventorycheckdetails:export")
    @Log(title = "盘点明细表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Inventorycheckdetails inventorycheckdetails)
    {
        List<Inventorycheckdetails> list = inventorycheckdetailsService.selectInventorycheckdetailsList(inventorycheckdetails);
        ExcelUtil<Inventorycheckdetails> util = new ExcelUtil<Inventorycheckdetails>(Inventorycheckdetails.class);
        return util.exportExcel(list, "盘点明细表数据");
    }

    /**
     * 新增盘点明细表
     */
    @RequiresPermissions("pims:inventorycheckdetails:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存盘点明细表
     */
    @RequiresPermissions("pims:inventorycheckdetails:add")
    @Log(title = "盘点明细表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Inventorycheckdetails inventorycheckdetails)
    {
        return toAjax(inventorycheckdetailsService.insertInventorycheckdetails(inventorycheckdetails));
    }

    /**
     * 修改盘点明细表
     */
    @RequiresPermissions("pims:inventorycheckdetails:edit")
    @GetMapping("/edit/{detailId}")
    public String edit(@PathVariable("detailId") Long detailId, ModelMap mmap)
    {
        Inventorycheckdetails inventorycheckdetails = inventorycheckdetailsService.selectInventorycheckdetailsByDetailId(detailId);
        mmap.put("inventorycheckdetails", inventorycheckdetails);
        return prefix + "/edit";
    }

    /**
     * 修改保存盘点明细表
     */
    @RequiresPermissions("pims:inventorycheckdetails:edit")
    @Log(title = "盘点明细表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Inventorycheckdetails inventorycheckdetails)
    {
        return toAjax(inventorycheckdetailsService.updateInventorycheckdetails(inventorycheckdetails));
    }

    /**
     * 删除盘点明细表
     */
    @RequiresPermissions("pims:inventorycheckdetails:remove")
    @Log(title = "盘点明细表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(inventorycheckdetailsService.deleteInventorycheckdetailsByDetailIds(ids));
    }
}
